<!DOCTYPE html>
<html data-theme="dark">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="theme-color" content="#0d1116" media="(prefers-color-scheme: dark)">
  <meta name="theme-color" content="#C0C0C0" media="(prefers-color-scheme: light)">
  <title>ASN.1 JavaScript decoder</title>
  <link rel="stylesheet" href="index.css" type="text/css">
  <link rel="icon" type="image/svg+xml" sizes="192x192" href="favicon.svg">
</head>
<body>
  <div id="contextmenu">
    <button id="btnCopyHex">Copy hex dump</button>
    <button id="btnCopyB64">Copy Base64</button>
    <button id="btnCopyTree">Copy subtree</button>
    <button id="btnCopyValue">Copy value</button>
  </div>
  <header>
    <div class="title">
      <h1>ASN.1 JavaScript decoder</h1>
    </div>
    <div class="menu">
      <form>
        <input id="butClear" type="button" value="clear">
        <select id="theme-select">
          <option value="os">OS Theme</option>
          <option value="dark">Dark Theme</option>
          <option value="light">Light Theme</option>
        </select>
      </form>
    </div>
  </header>
  <div id="main-page">
    <div>
      <div id="dump"></div>
      <div id="tree"></div>
    </div>
    <form>
      <textarea id="area" rows="8" placeholder="Paste hex or base64 or PEM encoded ASN.1 BER or DER structures here, or load a file."></textarea>
      <br>
      <br>
      <label title="can be slow with big files"><input type="checkbox" id="wantHex" checked="checked"> with hex dump</label>
      <label title="can be slow with big files"><input type="checkbox" id="trimHex" checked="checked"> trim big chunks</label>
      <label title="can be slow with big files"><input type="checkbox" id="wantDef" checked="checked"> with definitions</label>
      <input id="butDecode" type="button" value="decode">
      <br><br>
      <table>
        <tr><td>Drag or load file:</td><td><input type="file" id="file"></td></tr>
        <tr id="rowExamples"><td>Load examples:</td><td>
          <select id="examples">
            <option value="sig-p256-der.p7m">PKCS#7/CMS attached signature (DER)</option>
            <option value="sig-p256-ber.p7m">PKCS#7/CMS attached signature (BER)</option>
            <option value="sig-rsa1024-sha1.p7s">PKCS#7/CMS detached signature (old)</option>
            <option value="cms-password.p7m">PKCS#7/CMS encrypted with password</option>
            <option value="letsencrypt-x3.cer">X.509 certificate: Let's Encrypt X3</option>
            <option value="ed25519.cer">X.509 certificate: ed25519 (RFC 8410)</option>
            <option value="pkcs1.pem">PKCS#1 RSA key (RFC 8017)</option>
            <option value="pkcs8-rsa.pem">PKCS#8 RSA key (RFC 5208)</option>
            <option value="pkcs10.pem">PKCS#10 certification request (RFC 2986)</option>
            <option value="crl-rfc5280.b64">CRL example (RFC 5280)</option>
            <option value="cmpv2.b64">CMP PKI message (RFC 4210)</option>
            <option value="ldapmessage.b64">LDAP message (RFC 4511)</option>
            <option value="timestamp-req.b64">TimeStamp request (RFC 3161)</option>
          </select>
          <input id="butExample" type="button" value="load"><br>
        </td></tr>
        <tr><td>Definitions:</td><td><select id="definitions"></select></td></tr>
      </table>
    </form>
    <br>
  </div>
  <div id="help">
    <h2>Instructions</h2>
    <p>This page contains a JavaScript generic ASN.1 parser that can decode any valid ASN.1 DER or BER structure whether Base64-encoded (raw base64, PEM armoring and <span class="tt">begin-base64</span> are recognized) or Hex-encoded. </p>
    <p>This tool can be used online at the address <a href="https://asn1js.eu/"><span class="tt">https://asn1js.eu/</span></a> or offline, unpacking <a href="https://asn1js.eu/asn1js.zip">the ZIP file</a> in a directory and opening <span class="tt">index-local.html</span> in a browser.</p>
    <p>On the left of the page will be printed a tree representing the hierarchical structure, on the right side an hex dump will be shown. <br>
      Hovering on the tree highlights ancestry (the hovered node and all its ancestors get colored) and the position of the hovered node gets highlighted in the hex dump (with header and content in a different colors). <br>
      Clicking a node in the tree will hide its sub-nodes (collapsed nodes can be noticed because they will become <i>italic</i>).</p>
    <p><b>WARNING:</b> starting from 2024-03-28 this website is using ES6 features (and modules), which can break it for <a href="https://caniuse.com/es6-module">very old browsers</a>.<br>
      You can access <a href="https://rawcdn.githack.com/lapo-luchini/asn1js/1.2.4/index.html">last version before ES6 on githack</a> (which <a href="https://www.browserling.com/browse/win7/ie11/https://rawcdn.githack.com/lapo-luchini/asn1js/1.2.4/index.html">still works on IE11</a>).</p>
    <div class="license">
      <h3>Copyright</h3>
      <div><p class="hidden">
        ASN.1 JavaScript decoder<br>
        Copyright &copy; 2008-2025 Lapo Luchini <a href="mailto:lapo@lapo.it?subject=ASN1js">&lt;lapo@lapo.it&gt;</a><br>
        <br>
        Permission to use, copy, modify, and/or distribute this software for any
        purpose with or without fee is hereby granted, provided that the above
        copyright notice and this permission notice appear in all copies.<br>
        <br>
        THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
        WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
        MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
        ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
        WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
        ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
        OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
      </p></div>
      <p>ASN.1 JavaScript decoder Copyright &copy; 2008-2025 <a href="https://lapo.it/">Lapo Luchini</a>; released as <a href="https://opensource.org/licenses/isc-license.txt">opensource</a> under the <a href="https://en.wikipedia.org/wiki/ISC_licence">ISC license</a>.</p>
    </div>
    <p><span class="tt">OBJECT&nbsp;IDENTIFIER</span> values are recognized using data taken from Peter Gutmann's <a href="https://www.cs.auckland.ac.nz/~pgut001/#standards">dumpasn1</a> program.</p>
    <h3>Links</h3>
    <ul>
      <li><a href="https://asn1js.eu/">official website</a></li>
      <li><a href="https://lapo.it/asn1js/">alternate website</a></li>
      <li><a href="https://asn1js.eu/index-local.html">single-file version working locally</a> (just save this link)</li>
      <li>previous versions on githack: <select id="tags"><option>[select tag]</option></select></li>
      <li><a href="http://idf.lapo.it/p/asn1js/">InDefero tracker</a> (currently offline)</li>
      <li><a href="https://github.com/lapo-luchini/asn1js">github mirror</a></li>
      <li><a href="https://github.com/lapo-luchini/asn1js/blob/trunk/CHANGELOG.md">ChangeLog on GitHub</a></li>
      <li><a href="https://www.openhub.net/p/asn1js">OpenHub code stats</a></li>
    </ul>
  </div>
  <script type="module" src="index.js"></script>
</body>
</html>
